<template>
  <div class="vector-search">
    <el-input
      v-model="searchQuery"
      placeholder="输入搜索内容"
      style="width: 300px; margin-bottom: 20px;"
      @keyup.enter="handleSearch"
    />
    <el-table :data="searchResults" style="width: 100%">
      <el-table-column prop="result" label="搜索结果" />
    </el-table>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { ElMessage } from 'element-plus'
import { request } from '../../composables/useCommon'

const searchQuery = ref('')
const searchResults = ref([])

// 处理搜索
const handleSearch = async () => {
  try {
    const res = await request('ragVectorSearch/', 'get', { query: searchQuery.value })
    searchResults.value = res.data.records
  } catch (err) {
    ElMessage.error('搜索失败')
  }
}
</script>

<style scoped>
.vector-search {
  padding: 20px;
}
</style> 